<?php
namespace news;

use BaseController;
use View;
use News;
use Redirect;
use Input;

class IndexController extends BaseController {

	/**
	 * Display a listing of the resource.
	 * GET /news/index
	 *
	 * @return Response
	 */
	public function index()
	{
		$news = new News;
		$new_hot_news = $news->get();
		$all_news = $news->paginate(3);
		return View::make('news.index.index')->with('new_hot_news',$new_hot_news)->with('all_news',$all_news);
	}


	public function detail($id){
		$news = new News;
		$detail = $news->find($id);
		//上下一篇
		$prev_news = $news->where('id','<',$id)->orderBy('id','desc')->limit(1)->get()[0];
		$next_news = $news->where('id','>',$id)->orderBy('id','asc')->limit(1)->get()[0];

		return View::make('news.index.detail')->with('prev_news',$prev_news)->with('next_news',$next_news)->with('news',$detail);
	}
}